<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            margin: 0;
            padding: 0;
            font-family: '微软雅黑';
            background-color: #f7f7f7;
        }
        ul{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .wrapper{
            width: 1024px;
            margin: 0 auto;
        }
        .wrapper > section{
            min-height: 300px;
            margin-bottom: 30px;
            box-shadow: 1px 1px 4px #DDD;
            background-color: #fff;
        }
        .wrapper > header{
            text-align: center;
            line-height: 1;
            padding: 20px;
            margin-bottom: 10px;
            font-size: 30px;
        }
        .wrapper section > header{
            line-height: 1;
            padding: 10px;
            font-size: 22px;
            color: #333;
            background-color: #EEE;
        }
        .wrapper .wrap-box{
            padding: 20px;
        }

        form{
            width: 300px;
            height: 300px;
            margin: 0 auto;
        }

        form input[type="text"]{
            width: 200px;
            height: 30px;
        }

        form input[type="password"]{
            width: 200px;
            height: 30px;
        }

        section:nth-of-type(4) li:first-child span:only-child{
            color:red;
        }

        section:nth-of-type(4) li:nth-child(2) span:only-of-type{
            color:red;
        }

         section:nth-of-type(5) li:nth-child(n) {

             /*
                n = 2n;
                n = n;
                n = 3n;
                7n-1
                7n +1
                2n+1
             */
            color:red;
        }

        section:nth-last-of-type(2) p:empty{
            width: 20px;
            height: 20px;
            background-color: blue;
        }

        section:target{
            background: green;
        }

        section:last-child p:after{
            content: 'alter';
            color: red;
        }

        section:last-child p:before{
            content: 'before-';
            color: red;
        }

    </style>
</head>
<body>
    <div class="wrapper">
        <header>CSS3-属性选择器</header>
        <!--分隔线-->
        <section>
            <header>简介</header>
            <div class="wrap-box">
            </div>
        </section>
        <section id="demo1" class="">
            <header>E:first-child</header>
            <div class="wrap-box">
            </div>
        </section>
        <section id="demo2" class="">
            <header>E:last-child</header>
            <div class="wrap-box">
            </div>
        </section>
        <section id="demo3" class="">
            <header>E:only-child</header>
            <div class="wrap-box">
                <ul>
                    <li><span>我是span</span></li>
                    <li><span>我是li</span><p>111</p></li>
                    <li><span>我是li</span><span>111</span></li>
                    <li></li>
                    <li></li>
                </ul>
            </div>
        </section>
        <section class="">
            <header>E:nth-child(n)</header>
            <div class="wrap-box">
                <p>n的取值为大于等于1,当N作为系数时N的取值可以为0 比如2n+1</p>
                <ul>
                    <li><span>1我是span</span></li>
                    <li><span>2我是li</span></li>
                    <li><span>3我是li</span></li>
                    <li>4</li>
                    <li>5</li>
                    <li>6</li>
                </ul>
            </div>
        </section>
        <section class="">
            <header>E:nth-last-child(n)</header>
            <div class="wrap-box">

            </div>
        </section>
        <section class="">
            <header>E:first-of-type</header>
            <div class="wrap-box">

            </div>
        </section>
        <section class="">
            <header>E:last-of-type</header>
            <div class="wrap-box">

            </div>
        </section>
        <section class="">
            <header>E:only-of-type</header>
            <div class="wrap-box">

            </div>
        </section>
        <section class="">
            <header>E:nth-of-type(n)</header>
            <div class="wrap-box">

            </div>
        </section>
        <section class="">
            <header>E:empty</header>
            <div class="wrap-box">
                <span>E:empty 表示元素没有任何内容才被选中</span>
                <p></p>
            </div>
        </section>
        <section class="">
            <header>E:target</header>
            <div class="wrap-box">
                <a href="#demo1">demo1</a>
                <a href="#demo2">demo2</a>
                <a href="#demo3">demo3</a>
                <a href="#demo4">demo4</a>
            </div>
        </section>
        <section class="">
            <header>E:after</header>
            <div class="wrap-box">
               <p></p>
            </div>
        </section>

    </div>
</body>
</html>